package org.geekbang.projects.cs.im.config;

import org.geekbang.projects.cs.im.dto.IMLoginRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;

/**
 * @description:
 * @author: Kaijun Chen
 * @date: 2023/3/9
 **/
@Configuration
public class RedisConfig {

    @Bean
    public RedisTemplate<String, IMLoginRequest> requestRedisTemplate(RedisConnectionFactory connectionFactory) {
        RedisTemplate<String, IMLoginRequest> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(connectionFactory);
        redisTemplate.setKeySerializer(RedisSerializer.string());
        redisTemplate.setValueSerializer(RedisSerializer.json());
        return redisTemplate;
    }

}
